<template>
  <div>
    <h2>父组件</h2>
    <child-component :message="parentMessage" @childEvent="handleChildEvent"></child-component>
    <button @click="updateMessage">更新传递的数据</button>
  </div>
</template>

<script>
import ChildComponent from './ChildComponent.vue'

export default {
  components: {
    ChildComponent
  },
  data() {
    return {
      parentMessage: '来自父组件的初始数据'
    }
  },
  methods: {
    updateMessage() {
      this.parentMessage = '更新后的数据'
    },
    handleChildEvent(data) {
      console.log('接收到子组件数据:', data)
    }
  }
}
</script>